import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from "@/views/login/Login.vue"
Vue.use(VueRouter)

const originPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location){
  return originPush.call(this,location).catch(err => err)
}
const routes = [
    {
      path:"/",
      component:Login
    },
    {
      path:"/orders",
      component:()=> import("@/views/orders/Order-Item.vue"),
    },
    {
      path:"/home",
      component:() => import( '../views/home/home.vue')
    },
    {
        path:"/detail",
        name:"detail",
        component: () => import( '../views/detail/Detail.vue'),
    },
    // 分类页面路由 ----郭严蕊
    {
      path:"/ClassiFication",
      name:"classiFication",
      component:() => import( '@/views/classification/ClassiFication.vue'),
      // children:[
      //   {
      //     path:"/ClassiFication",
      //     component:() => import( '@/views/classification/ClassiFication.vue')
      //   },
      // ]
    },
    // 订单页路由
    {
      path:'/OrderView',
      name:'OrderView',
      component: () => import('../views/order/OrderView.vue'),
      children:[
        {
          path:'/',
          name:"OrderViewOrder",
          component: () => import('../views/order/components/ContentView.vue'),
        },
        {
          path:'/ContentView/detail',
          name:"OrderDetail",
          component:()=>import('../views/order/components/OrderDetail.vue'),
        },
        {
          path:'/OrderView/myself',
          name:"MyselfView",
          component: () => import('../views/order/components/MyselfView.vue'),
        },
        
      ]
    },
    // {
    //   path:'/Login',
    //   // component:Login,
    //   name:"Login",
    //   component: () => import(/* webpackChunkName: "about" */ '../views/login/Login.vue')
    // },
    {
      path:"/shoppingCar",
      name:"ShoppingCar",
      component: () => import('../views/shoppingCar/shoppingCar.vue')
    },
    {
      path:'/Login',
      name:"Login",
      component: () => import(/* webpackChunkName: "about" */ '../views/login/Login.vue')
  //   component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
    }
]

const router = new VueRouter({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes,
  scrollBehavior(e,from,scroll){
    console.log(scroll)
    if(scroll){
      return scroll
    }else{
      return {x:0,y:0}
    }
  }
})
// router.beforeEach((to,from,next)=>{
//   if(localStorage.getItem("token")){
//     next()
//   }else{
//     next('/Login')
//   }
// })

export default router
